package com.pingan.springboot_es_api.domain;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;

public class RestResult<T> implements Serializable {
    private static final long  serialVersionUID = 1L;
    @Override
    public String toString() {
        return "RestResult{" +
                "code=" + code +
                ", success=" + success +
                ", msg='" + msg + '\'' +
                ", url='" + url + '\'' +
                ", data=" + data +
                ", currentTime=" + currentTime +
                '}';
    }

    public RestResult() {
    }

    public RestResult(Integer code, boolean success, String msg, String url, T data, Timestamp currentTime) {
        this.code = code;
        this.success = success;
        this.msg = msg;
        this.url = url;
        this.data = data;
        this.currentTime = currentTime;
    }

    public RestResult(Integer code, boolean success, String msg, String url, T data) {
        this.code = code;
        this.success = success;
        this.msg = msg;
        this.url = url;
        this.data = data;
        this.currentTime = new Timestamp(new Date().getTime());
    }

    //http 状态码
    private Integer code;
    //请求成功返回true
    private boolean success;
    // 请求失败提示信息
    private String msg;
    // 访问的url
    private String url;
    // 获取的数据
    private T data;

    public Timestamp getCurrentTime() {
        return currentTime;
    }

    public void setCurrentTime(Timestamp currentTime) {
        this.currentTime = currentTime;
    }

    private Timestamp currentTime;

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
